package com.hello.rabbithandler;

import com.Constants;
import com.Emp;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Producer {
    @Autowired
    private AmqpTemplate template;

    public void send(Emp msg){
        System.out.println("send:Thread.currentThread().getName() = " + Thread.currentThread().getName());

        template.convertAndSend(Constants.QUEUE_NAME, msg);

        System.out.println("发送了消息(Emp)：" +msg);
    }

    public void send2(String msg){
        System.out.println("send:Thread.currentThread().getName() = " + Thread.currentThread().getName());

        template.convertAndSend(Constants.QUEUE_NAME, msg);

        System.out.println("发送了消息(string)：" +msg);
    }

    public void send3(Integer msg){
        System.out.println("send:Thread.currentThread().getName() = " + Thread.currentThread().getName());

        template.convertAndSend(Constants.QUEUE_NAME, msg);

        System.out.println("发送了消息(int)：" +msg);
    }
}
